﻿using System;
using System.Data;

using System.Configuration;

using System.Data.OleDb;

namespace SalesVMT
{
    public class clsConnection
    {
        public static OleDbConnection CreateConnection()
        {

            //String connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\SalesVMT.mdb";
            String connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\My Source\\SalesVMT_ACCESS\\SalesVMT\\SalesVMT.mdb";
            OleDbConnection conn = new OleDbConnection(connect);
            return conn;
        }
        public static DataSet Query(string _sql)
        {
            DataSet _ds = new DataSet();
            OleDbDataAdapter _adapter = new OleDbDataAdapter();
            OleDbConnection _conn = clsConnection.CreateConnection();
            _adapter.SelectCommand = new OleDbCommand(_sql, _conn);
            _adapter.Fill(_ds);
            _conn.Close();
            return _ds;

        }
        public static bool Query1(string _sql)
        {
            bool retVal = false;
            OleDbConnection dbConn = CreateConnection();
            OleDbCommand dbCmd = new OleDbCommand(_sql, dbConn); 
            dbCmd.CommandType = CommandType.Text;
            try
            {
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
                retVal = true;
            }
            finally
            {
                dbConn.Close();
            }
            return retVal;
        }
    }
}
